package com.eshop.controller.good;

import com.eshop.pojo.Good;
import com.eshop.pojo.RespBean;
import com.eshop.pojo.RespPageBean;
import com.eshop.service.GoodService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "历史商品管理相关")
@RestController
@RequestMapping("/good/history")
public class GoodHistoryController {
    @Autowired
    GoodService goodService;

    //分页获取已下架商品列表
    @ApiOperation("分页获取已下架商品列表")
    @GetMapping("/")
    public RespPageBean getHistoryGoodByPage(@RequestParam(defaultValue = "1") Integer currentPage,
                                             @RequestParam(defaultValue = "8") Integer size, Good good) {
        return goodService.getHistoryGoodByPage(currentPage, size,good);
    }

    @ApiOperation("删除历史商品")
    @DeleteMapping("/{id}")
    public RespBean DeleteHistoryGood(@PathVariable int id){
        if (goodService.delGood(id) == 1){
            return RespBean.success("删除成功！");
        }
        return RespBean.error("删除失败！");
    }

//    @ApiOperation("重新上架商品")
//    @PutMapping("/")
//    public RespBean reSellGood(@PathVariable int id){
//        if (goodService.reSellGood(id) == 1){
//            return RespBean.success("解冻成功！");
//        }
//        return RespBean.error("解冻失败！");
//    }
}
